package com.mcptt.config.body.info.mcvideo;

import java.io.UnsupportedEncodingException;

import com.cloudptt.api.product.func.call.CallAttr;
import com.cloudptt.api.product.log.Log;
import com.mcptt.config.body.info.mcptt.McpttInfoBody;

public class McpttvideoBody_PCall extends McpttInfoBody{

	private int callType = CallAttr.CallType_Private;
	private int callDir = CallAttr.CallDir_MO;
	private String selfMcvideoId = "";
	private boolean isEmergency = true;
//	private boolean isAlert = true;
	private String funcNum = null;

	public McpttvideoBody_PCall(int callType,int callDir,String selfMcvideoId,boolean isEmergency,String funcNum)
	{
		this.callType = callType;
		this.callDir = callDir;
		this.selfMcvideoId = selfMcvideoId;
		this.isEmergency = isEmergency;
		this.funcNum = funcNum;
	}

	public String toString()
	{
		StringBuffer strBuff = new StringBuffer();
		strBuff.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>").append("\r\n");
		strBuff.append("<mcvideoinfo xmlns=\"urn:3gpp:ns:mcvideoInfo:1.0\">").append("\r\n");
		strBuff.append("<mcvideo-Params>").append("\r\n");
		//strBuff.append("<mcvideo-request-uri type=\"Normal\">").append("\r\n");
		strBuff.append("<session-type>").append(getCallTypeDesc(callType)).append("</session-type>").append("\r\n");
		//strBuff.append("</ mcvideo-request-uri>").append("\r\n");
		if(callDir == CallAttr.CallDir_MT) {
			strBuff.append("<mcvideo-called-party-id type=\"Normal\">").append("\r\n");
			strBuff.append("<mcvideoURI>").append(selfMcvideoId).append("</mcvideoURI>").append("\r\n");
			strBuff.append("</mcvideo-called-party-id>").append("\r\n");
		}
		if(isEmergency) {
			strBuff.append("<emergency-ind type=\"Normal\">").append("\r\n");
			strBuff.append("<mcvideoBoolean>").append(getBooleanDesc(isEmergency)).append("</mcvideoBoolean>").append("\r\n");
			strBuff.append("</emergency-ind>").append("\r\n");
		}
//		strBuff.append("<alert-ind type=\"Normal\">").append("\r\n");
//		strBuff.append("<mcvideoBoolean>").append(getBooleanDesc(isAlert)).append("</mcvideoBoolean>").append("\r\n");
//		strBuff.append("</alert-ind>");
		Log.debug(this.getClass(),"toString  funcNum = " + funcNum);
		if(funcNum != null
			&& funcNum.length() > 0)
		{
			strBuff.append("<functional-alias-URI>").append("\r\n");
			strBuff.append("<mcvideoURI>").append(funcNum).append("</mcvideoURI>").append("\r\n");
			strBuff.append("</functional-alias-URI>").append("\r\n");

//			strBuff.append("<mcvideo-calling-user-id>").append("\r\n");
//			strBuff.append("<mcvideoURI>").append(selfMcvideoId).append("</mcvideoURI>").append("\r\n");
//			strBuff.append("</mcvideo-calling-user-id>").append("\r\n");
		}

		strBuff.append("</mcvideo-Params>").append("\r\n");
		strBuff.append("</mcvideoinfo>").append("\r\n");

		try {
			return new String(strBuff.toString().getBytes(),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return strBuff.toString();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
